var e = require("../../utils/config.js");

Page({
    data: {
        name: "",
        businessRepresentative: "",
        cityManager: "",
        activeMode: "",
        mainPushGoods: "",
        singleProductSales: "",
        todaySales: "",
        giftUseNumber: "",
        isHideMore: !1
    },
    onLoad: function(e) {
        var t = e.obj;
        if (t) {
            var a = JSON.parse(t);
            this.setData({
                isHideMore: !0,
                name: a.name,
                businessRepresentative: a.businessRepresentative,
                cityManager: a.cityManager,
                activeMode: a.activeMode,
                mainPushGoods: a.mainPushGoods,
                singleProductSales: a.singleProductSales,
                todaySales: a.todaySales,
                giftUseNumber: a.giftUseNumber
            });
        }
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getName: function(e) {
        this.setData({
            name: e.detail.value
        });
    },
    getBusinessRepresentative: function(e) {
        this.setData({
            businessRepresentative: e.detail.value
        });
    },
    getCityManager: function(e) {
        this.setData({
            cityManager: e.detail.value
        });
    },
    getActiveMode: function(e) {
        this.setData({
            activeMode: e.detail.value
        });
    },
    getMainPushGoods: function(e) {
        this.setData({
            mainPushGoods: e.detail.value
        });
    },
    getSingleProductSales: function(e) {
        this.setData({
            singleProductSales: e.detail.value
        });
    },
    getTodaySales: function(e) {
        this.setData({
            todaySales: e.detail.value
        });
    },
    getGiftUseNumber: function(e) {
        this.setData({
            giftUseNumber: e.detail.value
        });
    },
    apply: function() {
        var t = this;
        if (t.data.name) if (t.data.businessRepresentative) if (t.data.cityManager) if (t.data.activeMode) if (t.data.mainPushGoods) if (t.data.singleProductSales) if (t.data.todaySales) if (t.data.giftUseNumber) {
            wx.showLoading({
                mask: !0
            });
            var a = wx.getStorageSync("userId"), s = wx.getStorageSync("serviceProviderId");
            wx.request({
                url: e.urlList.API_ACTIVITY_REPORT_ADD,
                data: {
                    userId: a,
                    serviceProviderId: s,
                    name: t.data.name,
                    businessRepresentative: t.data.businessRepresentative,
                    cityManager: t.data.cityManager,
                    activeMode: t.data.activeMode,
                    mainPushGoods: t.data.mainPushGoods,
                    singleProductSales: t.data.singleProductSales,
                    todaySales: t.data.todaySales,
                    giftUseNumber: t.data.giftUseNumber
                },
                method: "POST",
                success: function(e) {
                    wx.hideLoading(), 200 == e.data.status ? (wx.navigateBack(), wx.showToast({
                        title: "新增成功"
                    })) : wx.showToast({
                        title: e.data.message,
                        icon: "none"
                    });
                }
            });
        } else wx.showToast({
            title: "请输入赠品使用数量",
            icon: "none"
        }); else wx.showToast({
            title: "请输入销售额",
            icon: "none"
        }); else wx.showToast({
            title: "请输入单品销售金额",
            icon: "none"
        }); else wx.showToast({
            title: "请输入品名",
            icon: "none"
        }); else wx.showToast({
            title: "请输入活动网点名称",
            icon: "none"
        }); else wx.showToast({
            title: "请输入城市经理姓名",
            icon: "none"
        }); else wx.showToast({
            title: "请输入业务代表姓名",
            icon: "none"
        }); else wx.showToast({
            title: "请输入活动名称",
            icon: "none"
        });
    },
    goToActivityReportHistory: function() {
        wx.navigateTo({
            url: "../work/activityReportHistory"
        });
    }
});